import React, { Component } from 'react';
import { Card, Button } from 'antd';
import styles from './style.less';



// eslint-disable-next-line react/prefer-stateless-function
class HeadLayout extends Component {
    constructor(props) {
        super(props);
        this.state = {
            isType: props.type ? props.type : '',
            isTitle: props.title ? props.title : ''
        }
    }
    
    render () {
        let IsButton

        if ( this.state.isType === 'edit' ) {
            IsButton = () => (
                <a href="" mtype="edit">编辑</a>
            )
        } else if ( this.state.isType === 'add' ){
            IsButton = () => (
                <Button icon="plus" type="primary">添加</Button>
            )
        } else (
            IsButton = () => (
                <div></div>
            )
        )
        return (
            <Card
                className={styles.basicHeadLayout}
                bordered={false}
            >
                <div className={styles.headName}>{this.state.isTitle}</div>
                <IsButton></IsButton>
            </Card>
        )
    }
}

export default HeadLayout